<!--
  权限表添加页面
  User: 高祥
  Date: 2020-02-13
-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >

    <div id="tree_2" class="tree-demo">
        <ul>
            <li data-jstree='{ "opened" : true ,"icon" : "fa fa-asterisk fa-spin icon-state-info"}' data-id="0" data-name="顶级目录">
                顶级目录（Root）
                <ul>
                    <th:block th:each="data,iterStat : ${roleList}" >
                        <li th:data-id="${data.id}"  th:data-jstree="${data.dataJsTree }">
                            <th:block th:text="${data.name}"></th:block>
                        </li>
                    </th:block>
                </ul>
            </li>
        </ul>
    </div>

    <script>
        $('#tree_2').jstree({
            "core" : {
                "themes" : {
                    "responsive": false
                }
            },
            'plugins': ["checkbox"]
        });

        /**
         * 获取全部选中节点
         */
        function getAllCheckedRole(){
            var checkedArray = new Array();

            /**
             * 获取选中节点
             * */
            var checkeds = $('#tree_2').jstree().get_checked(true);
            for(var c in checkeds){
                checkedArray.push(checkeds[c].data["id"]);
            }


            return checkedArray;
        }
    </script>
</html>